package com.hkpw.hik;

import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;

import java.util.HashMap;
import java.util.Map;

public class ArtemisUtil {

    /**
     * API网关的后端服务上下文为：/artemis
     */
    public static final String ARTEMIS_PATH = "/artemis";

    /**
     * 权限场景模块后端上下文为: /uamis
     */
    public static final String UAMIS_PATH = "/uamis";



    /**
     * POST公共方法，可传入上下文
     *
     * @param host
     * @param basePath  上下文
     * @param appKey
     * @param appSecret
     * @param path
     * @param body
     * @return
     */
    public static String callPostApiCommonFun(String host, String basePath, String appKey, String appSecret, String path, String body) {
        ArtemisConfig config = new ArtemisConfig(host, appKey, appSecret);
        Map<String, String> pathMap = new HashMap<String, String>(16);
        pathMap.put("https://", basePath + path);
        String result = null;
        try {
            result = ArtemisHttpUtil.doPostStringArtemis(config, pathMap, body, null, null, "application/json");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return result;
    }

    /**
     * POST公共方法
     *
     * @param path API接口地址
     * @param body 参数（JSON格式）
     * @return
     */
    public static String callPostApiCommonFun(String host, String appKey, String appSecret, String path, String body) {
        return callPostApiCommonFun(host, ARTEMIS_PATH, appKey, appSecret, path, body);
    }



}
